/* home script */
// change tab page
function changeTab(index) {
  var tabList = document.getElementById('tab-list').children
  var tabContent = document.getElementById('tab-content').children
  for (var i = 0; i < tabList.length; i++) {
    removeClassName(tabList[i], 'tab-item-active')
    tabContent[i].style.display = 'none'
  }
  addClassName(tabList[index], 'tab-item-active')
  tabContent[index].style.display = 'block'
}
// get current element about classname is hot-cont & hot-details
function getHotChildren(index) {
  var hot = document.getElementById('hot')
  var currentHotItem = hot.children[index]
  var elementList = currentHotItem.children
  var hotCont
  var hotDetails
  for (var i = 0; i < elementList.length; i++) {
    switch (elementList[i].className) {
      case 'hot-cont':
        hotCont = elementList[i]
        break
      case 'hot-details':
        hotDetails = elementList[i]
    }
  }
  return {
    hotCont: hotCont,
    hotDetails: hotDetails
  }
}
// show mask about details
function showDetailsMask(index) {
  var eleObj = getHotChildren(index)
  eleObj.hotCont.style.display = 'none'
  eleObj.hotDetails.style.display = 'block'
}
// hide mask about detatils
function hideDetailsMask(index) {
  var eleObj = getHotChildren(index)
  eleObj.hotCont.style.display = 'block'
  eleObj.hotDetails.style.display = 'none'
}
// main
window.onload = function () {
  swipeAutoplay()
}